package com.jia.jianzhiOffer;

/**
 * 剑指 Offer 58 - I. 翻转单词顺序
 */
public class Pro58_1 {
    public String reverseWords(String s) {
        String[] words = s.trim().split(" ");
        StringBuilder sb = new StringBuilder();
        for(int i = words.length-1; i >=0; i--) {
            if("".equals(words[i])) { continue; }
            sb.append(words[i]);
            if(i != 0) {
                sb.append(" ");
            }
        }
        return sb.toString();
    }
}
